﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Etapa1.SofRender
{
    public class BasicShader : SEffect,PixelShader,VertexShader
    {
        public BasicShader()
        {
            this.GeometricShader = null;
            this.PixelShader = this;
            this.VertexShader = this;
        }

        Matrix world = Matrix.Identity;

        public Matrix World
        {
            get { return world; }
            set { world = value; }
        }
        Matrix view = Matrix.Identity;

        public Matrix View
        {
            get { return view; }
            set { view = value; }
        }
        Matrix projection = Matrix.Identity;

        public Matrix Projection
        {
            get { return projection; }
            set { projection = value; }
        }

        #region VertexShader Members

        VertexType VertexShader.VertexShader(VertexType vertice)
        {
            Vector4 pos = vertice[Slots.POSITION0];            

            pos = Vector4.Transform(pos, World);
            pos = Vector4.Transform(pos, view);
            pos = Vector4.Transform(pos, projection);           

            VertexType output = new VertexType();
            output[Slots.POSITION0] = pos;
            output[Slots.COLOR0] = vertice[Slots.COLOR0];           
            return output;
        }

        #endregion

        #region PixelShader Members

        Color PixelShader.PixelShader(VertexType vo)
        {
            return new Color(vo[Slots.COLOR0]);
            //return Color.Green;
        }

        #endregion
    }
}
